// pages/project-detail/components/second/second.js
Component({
  properties: {
    secondList: {
      type: Object,
      value: {}
    }
  },
  observers:{
    secondList: function(newValue) {
      const steps = newValue.reviewProgresses.map((item, index) => {
        // 0 未开始 1进行中 2已完成
        let color = item.isfinish == 2 ? '#25B45D' : item.isfinish == 1 ? '#409EFF' : '#bdbdc6';
        // updateBy存在使用updateBy，不存在用createBy
        let desc = item.deptName + '-' + (item.updateBy ? item.updateBy : item.createBy)
        // reviewTime同理
        let time = item.reviewTime ? item.reviewTime : item.createTime
        return {
          text: '【' + item.reviewName + '】',
          color: color,
          time: time,
          desc: desc,
          reviewStatus: item.reviewStatus
        }
      })
      const num = newValue.schedule ? newValue.schedule.split('/') : '';
      let res_num = Number(num[0]) / Number(num[1]) * 100;
      const file = newValue.fileProgress ?  newValue.fileProgress.split('/') : '';
      let res_file = Number(file[0]) / Number(file[1]) * 100;
      this.setData({
        steps: steps,
        numberFinish: newValue.schedule || '0/0',
        numberFile: newValue.fileProgress || '0/0',
        percentFinish: res_num,
        percentFile: res_file
      })
      console.log(steps);
    }
  },
  /**
   * 组件的初始数据
   */
  data: {
    steps: [
      {
        text: '【材料上传】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: ''
      },
      {
        text: '【选择专家】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '2'
      },
      {
        text: '【会议预算】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '3'
      },
      {
        text: '【会议审核】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '4'
      },
      {
        text: '【评审】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '5'
      },
      {
        text: '【发文】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '6'
      },
      {
        text: '【决算审核】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '7'
      },{
        text: '【归档】',
        color: '',
        time: '',
        desc: '',
        reviewStatus: '8'
      },
    ],
    numberFinish: '',
    percentFinish: '',
    numberFile: '',
    percentFile: ''
  },
})